<template>
	<view class="page">

		<rich-text v-if="info" :nodes="info.content"></rich-text>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';
	export default {
		data() {
			return {
				info: null
			}
		},
		computed: {
			...mapState(['user', 'common'])
		},
		onLoad(option) {
			this.loadData(option.id)
		},
		methods: {
			async loadData(id) {
				let res = await this.$api.getArticleDetail({id:id});
				if (res.code == 1) {
					uni.setNavigationBarTitle({
						title:res.data.title
					})
					res.data.content = res.data.content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, (
						match, capture) => {
						var img =
							`<img style="display: block; max-width: 100%;" src="${this.$wanlshop.oss(capture)}">`;
						return img;
					});
					this.info = res.data;
				}
			}
		}
	}
</script>

<style lang="less" scoped>
.page {
	padding: 20rpx 30rpx;
}
</style>